package com.du.web.sample.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {
    /**
     * 获取字符串的MD5值
     * @param input 输入字符串
     * @return MD5加密后的字符串（32位小写）
     */
    public static String md5(String input) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] messageDigest = md.digest(input.getBytes());
            StringBuilder hexString = new StringBuilder();
            for (byte b : messageDigest) {
                String hex = Integer.toHexString(0xff & b);
                if (hex.length() == 1) hexString.append('0');
                hexString.append(hex);
            }
            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("MD5算法不存在", e);
        }
    }


    public static void main(String[] args) {
        String salt = "175647da063a0cebf48bb8245a88099e";
        String timestamp = String.valueOf(1752649217000L);
        String plaintext = "1500000200073623191,1500000200069769875";
        System.out.println(md5(md5(plaintext) + salt + timestamp));
    }
} 